﻿using System.Collections.Generic;
using AK.Wwise;
using AudioStudio;
using AudioStudio.Components;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.Media
{
    public class LoopAdjustToneSound : AudioEmitter3D
    {

        [SerializeField]
        public RTPC rtpc;

        [Range(0,100)]
        public float maxFactor = 100;
        
        [Range(0,100)]
        public float soundValue = 0;

        public List<string> soundList;

        public void SetSoundValue(float value)
        {
            soundValue = value * maxFactor * 0.01f;
            rtpc.SetValue(gameObject,soundValue);
        }

        public void PlaySound(string sName)
        {
            if (soundList == null) soundList = new List<string>();
            if(soundList.Contains(sName)) return;
            AudioManager.PlaySound(sName,this.gameObject);
            soundList.Add(sName);
        }

        public void StopSound(string sName)
        {
            if (soundList == null) soundList = new List<string>();
            AudioManager.StopSound(sName,this.gameObject);
            soundList.Remove(sName);
        }

        public void PlayVoice(string vName)
        {
            AudioManager.PlayVoice(vName,this.gameObject);
        }

        public void StopVoice(string vName)
        {
            AudioManager.StopVoice(vName);
        }
    }
}